package com.movie.playvideos;

import io.vov.vitamio.LibsChecker;
import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
import android.app.Activity;
import android.os.Bundle;

import com.movie.playvideos.common.ConnectToServer;
import com.movie.playvideos.common.ConnectToServer.GetStreammingUrl;

public class VideoViewDemo extends Activity implements GetStreammingUrl{
	public static final String Tag_Url_Video = "Tag_Url_Video";
	private VideoView mVideoView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		if (!LibsChecker.checkVitamioLibs(this))
			return;
		setContentView(R.layout.video_view_demo);
		mVideoView = (VideoView) findViewById(R.id.surface_view);
		
		String path = getIntent().getStringExtra(Tag_Url_Video);
		ConnectToServer.getStreamUrlFromData(this, path, this);
		
		/*
		
		*/
		
		
	}
	@Override
	public void getStreammingUrl(String url) {
		// TODO Auto-generated method stub
		mVideoView.setVideoPath(url);
		mVideoView.setMediaController(new MediaController(this));
		mVideoView.requestFocus();

		mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
			@Override
			public void onPrepared(MediaPlayer mediaPlayer) {
				// optional need Vitamio 4.0
				mediaPlayer.setPlaybackSpeed(1.0f);
			}
		});
	}
}
